package com.hzya.frame.mdm.mdmModule.config;

import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.List;

@Configuration
@EnableCaching
public class CacheConfig extends CachingConfigurerSupport {

    @Override
    @Bean
    public ConcurrentMapCacheManager cacheManager() {
        // 整合所有需要的缓存名称：原有的mdm相关缓存 + 新的业务缓存
        List<String> cacheNames = Arrays.asList(
                // 原有缓存（来自SimpleCacheManager的配置）
                "mdmModuleDb",
                "mdmModuleDbFileds",
                "mdmModule",
                // 新添加的业务缓存（来自之前的ConcurrentMapCacheManager配置）
                "sysApplicationPlugin",
                "IntegrationTask",
                "IntegrationTaskLiving"
        );
        ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
        cacheManager.setCacheNames(cacheNames); // 注册所有缓存名称
        return cacheManager;
    }
}
